package com.geekcattle.controller.goods;

import com.geekcattle.service.goods.GoodsService;
import com.geekcattle.util.MapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @program: geek-framework
 * @description:
 * @author: LQ
 * @create: 2019-04-19 22:34
 */
@RequestMapping("/goods")
@RestController//@Controller和@ResponseBody的组合
public class GoodsController {

    @Autowired
    private GoodsService goodsService;
    /**
     * 获取所有的商品
     * 分页查询所有商品和所有商品的种类
     * 需要支持多条件查询
     * 需要支持按照商品类型查询
     * @param map
     * @return  (可能这方法还需要修改)
     */
    @RequestMapping(value= "/getGoodsType" , method={RequestMethod. GET,RequestMethod.POST})
    public Map getGoodsType(@RequestParam Map map) {
        List<Map> getGoodsType = goodsService.getGoodsType(map);
//        List<Map> getGoodsType = goodsService.getAllGoods(map);
        return MapUtil.resultMap(getGoodsType);
    }

    /**
     * 获取商品
     * @param map
     * @return
     */
    @RequestMapping(value= "/getGoods" , method={RequestMethod. GET,RequestMethod.POST})
    public Map getGoods(@RequestParam Map map) {
        List<Map> goodsList = goodsService.getGoods(map);
        return MapUtil.resultMap(goodsList);
    }
}
